<template>
  <el-table :data="list" style="width: 100%;padding-top: 15px;">
    <el-table-column label="操作时间" width="150" align="center">
      <template slot-scope="scope">
        {{ scope.row.time  }}
      </template>
    </el-table-column>
    <el-table-column label="操作对象" min-width="120" >
      <template slot-scope="scope">
        <a href="#" style="color: #0a76a4">{{ scope.row.target  }}</a>
      </template>
    </el-table-column>
    <el-table-column label="操作类型" width="80" align="center">
      <template slot-scope="scope">
        {{ scope.row.operation }}
      </template>
    </el-table-column>
    <el-table-column label="操作模块" width="80" align="center">
      <template slot-scope="scope">
        {{ scope.row.module }}
      </template>
    </el-table-column>
    <el-table-column label="操作结果" width="80" align="center">
      <template slot-scope="{row}">
        <el-tag :type="row.success | statusFilter">
          {{ row.success?'成功':'失败' }}
        </el-tag>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import { fetchActivityList } from '@/api/dashboard'

export default {
  filters: {
    statusFilter(status) {
      console.log("status"+status)
      const statusMap = {
        true: 'success',
        false: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      list: null
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      console.log("activity List")
      fetchActivityList().then(response => {
        this.list = response.data.slice(0,8)
      })
    }
  }
}
</script>
